package com.sky.mapper;

import com.sky.entity.ShoppingCart;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface ShoppingCartMapper {

    /**
     * 查询购物车中的该商品
     * @param shoppingCart
     * @return
     */
    List<ShoppingCart> query(ShoppingCart shoppingCart);

    /**
     * 修改购物车商品数量
     * @param shoppingCart
     */
    @Update("update shopping_cart set number = #{number} where id = #{id}")
    void update(ShoppingCart shoppingCart);

    /**
     * 新增数据
     * @param shoppingCart
     */
    @Insert("insert into shopping_cart (name, image, user_id, dish_id, setmeal_id, dish_flavor,number, amount, create_time) " +
            "VALUES (#{name}, #{image}, #{userId}, #{dishId}, #{setmealId}, #{dishFlavor},#{number}, #{amount}, #{createTime}) ")
    void sava(ShoppingCart shoppingCart);

    /**
     *删除购物车中的商品
     * @param shoppingCart
     */
    void delete(ShoppingCart shoppingCart);

}
